﻿<UserControl x:Class="OI.Views.AppsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" xmlns:Media="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions" xmlns:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" mc:Ignorable="d">

    <Grid Style="{StaticResource MainSubcontent}">
        <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden" BorderBrush="Transparent">
            <ItemsControl x:Name="Items" Margin="24, 12, 12, 12">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid Name="ItemGrid" Background="Transparent" Margin="0,0,0,12" Height="96">
                        
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                        
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>

                            <!--Background-->
                            <Rectangle x:Name="contentHighlight" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Grid.RowSpan="2" 
                                       Stroke="Transparent" Fill="{StaticResource ThemeColorBrush}" Opacity="0.0" Stretch="Fill"
                                       Micro:Message.Attach="[Event MouseLeftButtonDown] = [Action Select($dataContext);]">

                                <Rectangle.Resources>
                                    <Storyboard x:Key="HLOFF">
                                        <DoubleAnimation Storyboard.TargetName="contentHighlight" 
                                                                 Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                                 Duration="0" To="0"/>
                                    </Storyboard>
                                    <Storyboard x:Key="HLON">
                                        <DoubleAnimation Storyboard.TargetName="contentHighlight" 
                                                                 Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                                 Duration="0" To="0.125"/>
                                    </Storyboard>
                                </Rectangle.Resources>

                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="MouseEnter">
                                        <Media:ControlStoryboardAction Storyboard="{StaticResource HLON}"/>
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="MouseLeave">
                                        <Media:ControlStoryboardAction Storyboard="{StaticResource HLOFF}"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Rectangle>

                            <!--THUMBNAIL-->
                            <Image  Source="{Binding ThumbnailURI}" IsHitTestVisible="False"
                                    Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" 
                                    VerticalAlignment="Top" HorizontalAlignment="Left"
                                    Width="96" Height="96" Margin="0,0,4,0"/>
                        
                            <!--TITLE-->
                            <TextBlock Text="{Binding Title}" Grid.Column="1" Grid.Row="0" IsHitTestVisible="False"
                                       Style="{StaticResource PageTitle}" FontSize="22" Margin="4,0,0,0" />
                        
                            <!--DESCRIPTION-->
                            <TextBlock Text="{Binding Description}" Grid.Column="1" Grid.Row="1" IsHitTestVisible="False"
                                       TextWrapping="Wrap" Style="{StaticResource ListItems}" Margin="4,0,0,0" />

                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
    </Grid>
</UserControl>
